package com.ruoyi.system.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.vo.TreeVo;
import com.ruoyi.system.service.IWmsProductCategoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WmsProductCategories;

/**
 * 商品分类Controller
 *
 * @author ruoyi
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/system/wmsProductCategories")
public class WmsProductCategoriesController extends BaseController
{
    @Autowired
    private IWmsProductCategoriesService wmsProductCategoriesService;

    /**
     * 查询商品分类列表
     */
    @SaCheckPermission("system:wmsProductCategories:list")
    @GetMapping("/list")
    public R<List<WmsProductCategories>> list(WmsProductCategories wmsProductCategories)
    {
        List<WmsProductCategories> list = wmsProductCategoriesService.selectWmsProductCategoriesList(wmsProductCategories);
        return R.ok(list);
    }

    /**
     * 导出商品分类列表
     */
    /*@SaCheckPermission("system:wmsProductCategories:export")
    @Log(title = "商品分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsProductCategories wmsProductCategories)
    {
        List<WmsProductCategories> list = wmsProductCategoriesService.selectWmsProductCategoriesList(wmsProductCategories);
        ExcelUtil<WmsProductCategories> util = new ExcelUtil<WmsProductCategories>(WmsProductCategories.class);
        util.exportExcel(response, list, "商品分类数据");
    }*/

    /**
     * 获取商品分类详细信息
     */
    @SaCheckPermission("system:wmsProductCategories:query")
    @GetMapping(value = "/{id}")
    public R<WmsProductCategories> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(wmsProductCategoriesService.selectWmsProductCategoriesById(id));
    }

    /**
     * 新增商品分类
     */
    @SaCheckPermission("system:wmsProductCategories:add")
    @Log(title = "商品分类", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsProductCategories wmsProductCategories)
    {
        return toAjax(wmsProductCategoriesService.insertWmsProductCategories(wmsProductCategories));
    }

    /**
     * 修改商品分类
     */
    @SaCheckPermission("system:wmsProductCategories:edit")
    @Log(title = "商品分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsProductCategories wmsProductCategories)
    {
        return toAjax(wmsProductCategoriesService.updateWmsProductCategories(wmsProductCategories));
    }

    /**
     * 删除商品分类
     */
    @SaCheckPermission("system:wmsProductCategories:remove")
    @Log(title = "商品分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsProductCategoriesService.deleteWmsProductCategoriesByIds(ids));
    }

    /**
     * 删除商品分类
     */
    @SaCheckPermission("system:wmsProductCategories:list")
	@GetMapping("/getTree")
    public R<List<TreeVo>> getTree(WmsProductCategories wmsProductCategories)
    {
        return R.ok(wmsProductCategoriesService.getTree(wmsProductCategories));
    }
}
